home *** CD-ROM | disk | FTP | other *** search
- System.out.println("======== Reading from the console ============");
- java.io.DataInputStream in = new java.io.DataInputStream(new java.io.BufferedInputStream(System.in));
-
- String s;
- java.util.Vector accountList = new java.util.Vector();
- try {
- while ((s = in.readLine()).length() != 0) {
- ch07.CheckingAccount ch = new ch07.CheckingAccount(s);
- System.out.println(ch);
- accountList.addElement(ch);
- }
- }
- catch (java.io.IOException e) {
- e.printStackTrace();
- }
-
- System.out.println("======== Writing File: DATA.TXT ============");
- java.io.DataOutputStream outFile = new java.io.DataOutputStream(new java.io.BufferedOutputStream(new java.io.FileOutputStream("Data.txt")));
- try {
- for (int i = 0; i < accountList.size(); i++) {
- s = ((ch07.CheckingAccount)accountList.elementAt(i)).getAccountId();
- System.out.println("Writing: " + s);
- outFile.writeBytes(s + "\n");
- }
- outFile.close();
- }
- catch (java.io.IOException e) {
- e.printStackTrace();
- }
-
- System.out.println("======== Reading File: DATA.TXT ============");
- java.io.DataInputStream inFile = new java.io.DataInputStream(new java.io.BufferedInputStream(new java.io.FileInputStream("Data.txt")));
- try {
- while ((s = inFile.readLine()) != null) {
- ch07.CheckingAccount ch = new ch07.CheckingAccount(s);
- System.out.println(ch);
- }
- }
- catch (java.io.IOException e) {
- e.printStackTrace();
- }